package com.example.tests;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;

import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;

import com.example.fw.ContactObject;
import com.example.fw.Contacts;

public class ContactRemovalTests extends TestBase {

	@Test
	public void testSomeContactCanBeRemoved() throws Exception {
		for (int i = 0; i < 2; i++) {
			Contacts oldContactList = app.getContactHelper().getContacts();
			ContactObject someContactToDelete = oldContactList.takeSomeContactFromList();
			app.getContactHelper().deleteContact(someContactToDelete);
			Contacts newContactList = app.getContactHelper().getContacts();
			assertThat(newContactList, equalTo(oldContactList.withOut(someContactToDelete)));
		}
	}
	
//	@AfterMethod		// lesson 7 ~ 75:00
//	public void testUiConformsWithDb()	{
//		if ((app.getProperty("ui.check") != null) && (app.getProperty("db.check") != null))	{
//			Contacts uiList = app.getContactHelper().getUiContacts();
//			Contacts dbList = app.getHibernateHelper().getContacts();
//			assertThat(uiList, equalTo(dbList));
//		}
//	}
}